[v24.x backport] http2: avoid UAF while receiving and sending RST_STREAM - #65093
Open
mcollina wants to merge 2 commits into
Open
[v24.x backport] http2: avoid UAF while receiving and sending RST_STREAM#65093mcollina wants to merge 2 commits into
mcollina wants to merge 2 commits into
Conversation
Mark the session as receiving around nghttp2_session_mem_recv() and defer RST_STREAM handling while receive is in progress. This prevents closing a stream while nghttp2 still processes it and avoids heap-use-after-free in nghttp2_session_mem_recv2(). Fixes: nodejs#64113 Signed-off-by: Evgeniy Gorbanev <gorbanev.es@gmail.com> PR-URL: nodejs#64166 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> (cherry picked from commit 46de80d)
Node.js v24 does not include the later stream lifecycle changes that the original fix relies on. Preserve its reset ordering, avoid JavaScript callbacks after a deferred session close, and let destroyed streams finish without requesting trailers. Signed-off-by: Matteo Collina <hello@matteocollina.com> (cherry picked from commit 687a46df60e6211a6d0fbdcf3513125299440ae3)
Collaborator
|
Review requested:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v24.x-staging #65093 +/- ##
=================================================
+ Coverage 89.92% 90.29% +0.36%
=================================================
Files 686 711 +25
Lines 208389 228175 +19786
Branches 40077 43141 +3064
=================================================
+ Hits 187387 206023 +18636
- Misses 13238 14091 +853
- Partials 7764 8061 +297
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backports #64166 to
v24.x-staging.The direct cherry-pick relies on newer HTTP/2 stream lifecycle behavior that is not present in Node.js 24. The second commit preserves v24's reset ordering, avoids JavaScript callbacks after a session close is deferred out of
nghttp2_session_mem_recv(), and lets destroyed streams finish without requesting trailers.This addresses the memory corruption reported in #64841, where the corrupted state generally surfaced later in V8's concurrent Maglev compiler.
The release build passed all 278
parallel/test-http2-*tests. The Undici reproducer also completed 96/96 concurrent reduced runs and 16/16 concurrent originalnode:testruns without an abnormal exit.